package com.sc.nft.admin.controller;


import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.SpecialEventManagementBindingEditDTO;
import com.sc.nft.entity.dto.SpecialEventManagementBindingSaveDTO;
import com.sc.nft.entity.vo.SpecialEventManagementBindingVO;
import com.sc.nft.service.SpecialEventManagementBindingService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 专场管理(SpecialEventManagementBinding)表控制层
 *
 * @author 王伟成
 * @since 2023-10-10 16:01:03
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/specialEventManagementBinding")
@Api(tags = "专场管理绑定藏品")
@Valid
public class SpecialEventManagementBindingController {
    /**
     * 服务对象
     */
    private final SpecialEventManagementBindingService specialEventManagementBindingService;


    @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result save(@RequestBody SpecialEventManagementBindingSaveDTO specialEventManagementBindingSaveDTO) {
        specialEventManagementBindingService.save(specialEventManagementBindingSaveDTO);
        return Result.success();
    }

    @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑", notes = "编辑", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result edit(@RequestBody SpecialEventManagementBindingEditDTO specialEventManagementBindingEditDTO) {
        specialEventManagementBindingService.edit(specialEventManagementBindingEditDTO);
        return Result.success();
    }

    @PostMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取该专场绑定的nft集合数据", notes = "获取该专场绑定的nft集合数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<SpecialEventManagementBindingVO>> list(@RequestBody IdRequest idRequest) {
        return Result.success(specialEventManagementBindingService.list(idRequest.getId()));
    }


    @PostMapping(value = "/removeById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除单条", notes = "删除单条", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result removeById(@RequestBody IdRequest idRequest) {
        specialEventManagementBindingService.removeById(idRequest.getId());
        return Result.success();
    }

}
